// Copyright (c) 2024 CHANGLEI. All rights reserved.

import 'package:charts_grasp/src/chart/chart_series/series.dart';
import 'package:charts_grasp/src/chart/chart_series/xy_data_series.dart';
import 'package:charts_grasp/src/chart/common/marker.dart';
import 'package:charts_grasp/src/chart/user_interaction/trackball_marker_setting_renderer.dart';
import 'package:charts_grasp/src/chart/utils/enum.dart';
import 'package:flutter/material.dart';

class TrackballMarkerSettings extends MarkerSettings {
  const TrackballMarkerSettings({
    this.markerVisibility = TrackballVisibilityMode.auto,
    super.height = null,
    super.width = null,
    super.color,
    super.shape,
    super.borderWidth,
    super.borderColor,
    super.image,
  });

  final TrackballVisibilityMode markerVisibility;

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }

    return other is TrackballMarkerSettings &&
        other.markerVisibility == markerVisibility &&
        other.height == height &&
        other.width == width &&
        other.color == color &&
        other.shape == shape &&
        other.borderWidth == borderWidth &&
        other.borderColor == borderColor &&
        other.image == image;
  }

  @override
  int get hashCode {
    final List<Object?> values = <Object?>[
      markerVisibility,
      height,
      width,
      color,
      shape,
      borderWidth,
      borderColor,
      image,
    ];
    return Object.hashAll(values);
  }
}

@immutable
class TrackballDetails {
  const TrackballDetails([this.point, this.series, this.pointIndex, this.seriesIndex, this.groupingModeInfo]);

  final CartesianChartPoint<dynamic>? point;

  final CartesianSeries<dynamic, dynamic>? series;

  final int? pointIndex;

  final int? seriesIndex;

  final TrackballGroupingModeInfo? groupingModeInfo;

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }

    return other is TrackballDetails &&
        other.point == point &&
        other.series == series &&
        other.pointIndex == pointIndex &&
        other.seriesIndex == seriesIndex &&
        other.groupingModeInfo == groupingModeInfo;
  }

  @override
  int get hashCode {
    final List<Object?> values = <Object?>[point, series, pointIndex, seriesIndex, groupingModeInfo];
    return Object.hashAll(values);
  }
}
